@extends('layouts/app')

@section('content')

<div class="shops white-bg">
    {{--店铺信息--}}
    <div class="shops-info row">
        <div class="col-8">
            <h1 class="shops-title f30">{{$data['shop_name']}}</h1>
            <input type="hidden" name="id" value="{{$data['id']}}">
            <p class="start">
                @for ($i = 1; $i <= 5; $i++)
                    @if ($data['shopinfo']['score'] >= $i)
                        <svg class="icon f28 orange" aria-hidden="true">
                        @else
                        <svg class="icon f28" aria-hidden="true">
                    @endIf
                        <use xlink:href="#icon-star-fill"></use>
                    </svg>
                @endfor
               <span class="f30">{{$data['shopinfo']['score']}}</span>
            </p>
            <span>{{ $data['shopinfo']['score'] >= $i}}</span>
            <p class="serve">
                @if ($data['shopinfo']['is_wifi'])
                <svg class="icon f48 gary6" aria-hidden="true">
                    <use xlink:href="#icon--24"></use>
                </svg>
                @endif
                @if ($data['shopinfo']['is_pickup'])
                <svg class="icon f48 gary6" aria-hidden="true">
                    <use xlink:href="#icon--26"></use>
                </svg>
                @endif
                @if ($data['shopinfo']['is_pickup'])
                <svg class="icon f48 gary6" aria-hidden="true">
                    <use xlink:href="#icon--23"></use>
                </svg>
                @endif
            </p>
        </div>
        <div class="col-4">
            <div class="shops-img">
                @if (!empty($data['shop_pic']))
                    <img src="{{$data['shop_pic']}}" alt="" class="img-responsive">
                @else
                    <img src="/img/eat.png" alt="" class="img-responsive">
                @endif
            </div>
            <div class="video">

            </div>
        </div>
    </div>
    {{--排队+外卖--}}
    <div class="btn-box weui-flex">
        @if ($data['is_list'])
        <div class="weui-flex__item">
            <a href="/mobile/takeout-line?id={{$data['id']}}&type=line" class="weui-btn weui-btn_plain-default f22">
                <svg class="icon2 f48 orange mr-5" aria-hidden="true">
                    <use xlink:href="#icon--10 "></use>
                </svg>排队订座
            </a>
        </div>
        @endif
        @if ($data['is_takeout'])
       <div class="weui-flex__item">
           <a href="/mobile/takeout-menu?id={{$data['id']}}&type=takeout" class="weui-btn weui-btn_plain-default f22">
               <svg class="icon2 f48 orange mr-5" aria-hidden="true">
                   <use xlink:href="#icon--28"></use>
               </svg>外卖</a>
       </div>
        @endif
    </div>
    {{--其它信息--}}
    <div class="other-info">
        <p>
            <svg class="icon f32 gary3" aria-hidden="true">
                <use xlink:href="#icon--27"></use>
            </svg>
            <span class="f30">营业时间：{{$data['shopinfo']['opentime']}}</span>
        </p>
        <p class="nowrap">
            <svg class="icon f32 gary3" aria-hidden="true">
                <use xlink:href="#icon-tubiao-5"></use>
            </svg>
            <span class="f30">地址：{{$data['shop_address']}}</span>
        </p>
        <p class="nowrap">
            <svg class="icon f32 gary3" aria-hidden="true">
                <use xlink:href="#icon--29"></use>
            </svg>
            <span class="f30">电话：{{$data['shop_phone']}}</span>
        </p>
        {{--<div class="call row">--}}
            {{--<div class="call-car pull-left">--}}
                {{--<p>--}}
                    {{--<svg class="icon f30 gary6" aria-hidden="true">--}}
                        {{--<use xlink:href="#icon--11"></use>--}}
                    {{--</svg>--}}
                {{--</p>--}}
                {{--<p class="f14">打车</p>--}}
            {{--</div>--}}
            {{--<div class="call-phone pull-left">--}}
                {{--<p>--}}
                    {{--<svg class="icon f30 gary6" aria-hidden="true">--}}
                        {{--<use xlink:href="#icon-tubiao-1"></use>--}}
                    {{--</svg>--}}
                {{--</p>--}}
                {{--<p class="f14">电话</p>--}}
            {{--</div>--}}
        {{--</div>--}}
    </div>
    {{--预约时间--}}
    @if ($data['is_reserve'])
    <div class="demos-content-padded">
        <a href="javascript:;" id="resver-btn" class="weui-btn weui-btn_primary f30">预定</a>
    </div>
    @endif

    {{--活动和优惠--}}
    {{--<div class="list-panel">--}}
        {{--<div class="act">--}}
            {{--<a href="javascript:;" class="weui-btn weui-btn_mini weui-btn_primary f22">活动</a>--}}
            {{--<span class="f30">在线支付立减10元</span>--}}
        {{--</div>--}}
        {{--<div class="pre">--}}
            {{--<a href="javascript:;" class="weui-btn weui-btn_mini weui-btn_primary f22">活动</a>--}}
            {{--<span class="f30">首单立减5-99元</span>--}}
        {{--</div>--}}
    {{--</div>--}}

    <div class="shops-content">
        <!-- 容器 -->
        <div class="weui-tab">
            <div class="weui-navbar">
                <a class="weui-navbar__item weui-bar__item--on f28" href="#tab1">
                    包间
                </a>
                <a class="weui-navbar__item f28" href="#tab2">
                    大厅
                </a>
                <a class="weui-navbar__item f28" href="#tab3">
                    评论
                </a>
            </div>
            <div class="weui-tab__bd">
                <div id="tab1" class="weui-tab__bd-item weui-tab__bd-item--active">
                    <ul class="list-unstyled rooms-list list">
                        @if(isset($data->shoproomtable))
                            @foreach($data->shoproomtable as $room)
                                @if ($room->type == 1)
                                    <li class="row">
                                        <a href="/mobile/room-detail?id={{$room->id}}" class="gary3">
                                            <div class="col-12">
                                                <p class="rooms-title f30">{{$room->name}}</p>
                                                <p class="rooms-info f26">
                                                    <span class="mr-5">最低消费{{$room->min_consumption}}元</span>
                                                    <span class="mr-5">可容纳{{$room->hold}}人</span>
                                                </p>
                                            </div>
                                        </a>
                                    </li>
                                @endif

                            @endforeach
                        @endif
                        {{--<li class="row">--}}
                            {{--<div class="col-12">--}}
                                {{--<p class="rooms-title f30">包间名称</p>--}}
                                {{--<p class="rooms-info f18">--}}
                                    {{--<span class="mr-5">最低消费0元</span>--}}
                                    {{--<span class="mr-5">可容纳20人</span>--}}
                                {{--</p>--}}
                            {{--</div>--}}
                        {{--</li>--}}
                        {{--<li class="row">--}}
                            {{--<div class="col-12">--}}
                                {{--<p class="rooms-title f30">包间名称</p>--}}
                                {{--<p class="rooms-info f18">--}}
                                    {{--<span class="mr-5">最低消费0元</span>--}}
                                    {{--<span class="mr-5">可容纳20人</span>--}}
                                {{--</p>--}}
                            {{--</div>--}}
                        {{--</li>--}}
                    </ul>
                </div>
                <div id="tab2" class="weui-tab__bd-item">
                    <ul class="list-unstyled hall-list list">
                        @if(isset($data->shoproomtable))
                            @foreach($data->shoproomtable as $room)
                                @if ($room->type == 0)
                                    <li class="row">
                                        <a href="/mobile/room-detail?id={{$room->id}}" class="gary3">
                                            <div class="col-12">
                                                <p class="rooms-title f30">{{$room->name}}</p>
                                                <p class="rooms-info f26">
                                                    <span class="mr-5">最低消费{{$room->min_consumption}}元</span>
                                                    <span class="mr-5">可容纳{{$room->hold}}人</span>
                                                </p>
                                            </div>
                                        </a>
                                    </li>
                                @endif
                            @endforeach
                        @endif
                    </ul>
                </div>
                {{--comment--}}
                <div id="tab3" class="weui-tab__bd-item">
                    <ul class="list-unstyled comments-list">
                        @if(isset($data->shoproomtable))
                            @foreach($data->shopcomment as $co)
                                <li>
                                    <div class="row padding">
                                        <div class="col-2">
                                            {{--暂时这样用着，到时候让前端再改吧--}}
                                            @if(isset($co->users->avatar))
                                                <img src="{{$co->users->avatar}}" alt="" class="img-responsive" style="border-radius: 1rem;">
                                            @else
                                                <img src="/img/aq.png" alt="" class="img-responsive" style="border-radius: 1rem;">
                                            @endif
                                        </div>
                                        <div class="col-10">
                                            <div class="text">
                                                <h4 class="f24 gary9">
                                                    {{$co->users->name}}
                                                    <span class="pull-right f20 gary9">{{$co->created_at}}</span>
                                                </h4>
                                                <p class="f24 content">{{$co->content}}</p>
                                            </div>
                                        </div>
                                    </div>
                                </li>
                            @endforeach
                        @endif
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>



    <script>
        // 时间弹窗
        $("#resver-btn").datetimePicker({
            onClose: function (res) {
                var shopsId = $("input[name='id']").val();
                console.log("shopsId", shopsId);
                console.log("我关闭了", res);
                console.log("我关闭了", res.value);
                var arr = res.value,
                    time = "";
                time += arr[0] + "-" + arr[1] + "-" + arr[2] + " " + arr[3] + ":" + arr[4];
                console.log("time", time);

                $.get("/api/checkDeskRoom", {arrive_time: time, shop_id: shopsId}, function (res) {

                    if (typeof res === 'string') {
                        res = JSON.parse(res);
                    }
                    if (res.code == 200) {
                        // 把房间数据缓存下来
                        var arr = [];
                        var room = res.data;

                        arr[shopsId] = room;

                        Storage.set("rooms", arr);
                        Storage.set("arriveTime", time);
                        location.href = "/mobile/takeout-booking?shopsId=" + shopsId;
                    } else {
                        $.toast(res.info, 'text')
                    }
                    console.log("res", res);
                });
            }
        });
    </script>
@endsection

@extends('layouts/footer')
